using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI.WebControls;
using btnet;

/// <summary>
/// Summary description for select_report
/// </summary>
public partial class select_report : System.Web.UI.Page
{
    protected DataSet ds;
    protected Security security;

    void Page_Load(Object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            String footer_label = null;
            if (Application["custom_footer"] != null)
            {
                footer_label = (String)Application["custom_footer"];
            }
            custom_footer_label.Text = footer_label;
        }

	    Util.do_not_cache(Response);
	
	    security = new Security();
	    security.check_security( HttpContext.Current, Security.ANY_USER_OK);

	    if (security.user.is_admin || security.user.can_use_reports)
	    {
		    //
	    }
	    else
	    {
		    Response.Write ("You are not allowed to use this page.");
		    Response.End();
	    }

	    titl.InnerText = Util.get_setting("AppTitle","BugTracker.NET") + " - "
		    + "reports";

	    string sql = @"
    select
    rp_desc [report],
    case
	    when rp_chart_type = 'pie' then
		    '<a href=''javascript:select_report(""pie"",' + convert(varchar, rp_id) + ')''>select pie</a>'
	    when rp_chart_type = 'line' then
		    '<a href=''javascript:select_report(""line"",' + convert(varchar, rp_id) + ')''>select line</a>'
	    when rp_chart_type = 'bar' then
		    '<a href=''javascript:select_report(""bar"",' + convert(varchar, rp_id) + ')''>select bar</a>'
	    else
		    '&nbsp;' end [chart],
    '<a href=''javascript:select_report(""data"",' + convert(varchar, rp_id) + ')''>select data</a>' [data]
    from reports order by rp_desc";

        ds = btnet.DbUtil.get_dataset(sql);

    }
}